//
// Created by zhaog on 31/03/17.
//

#include <Poco/Logger.h>
#include "req_handler.h"
#include "Poco/Stopwatch.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "sys_config.h"

namespace img_svr{
    void ReqHandler::handleRequest(HTTPServerRequest &request, HTTPServerResponse &response) {
        _req_http_version=request.getVersion();
        _req_method=request.getMethod();
        _req_client_host=request.clientAddress().toString();
        _req_uri=request.getURI();
        _content_length=(int)request.getContentLength();
        Poco::Stopwatch sw;
        sw.start();
        this->handleRequestImpl(request,response);
        sw.stop();
        long long time=sw.elapsed();
        HttpLog.information("%s %s %s %d %s %d %dms",_req_method,_req_uri,_req_http_version,_content_length,_req_client_host,(int)response.getStatus(),(int)time/1000);
    }
}